import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import AutoImport from "unplugin-auto-import/vite";
import Components from "unplugin-vue-components/vite";
import { ElementPlusResolver } from "unplugin-vue-components/resolvers";
// https://vitejs.dev/config/
export default defineConfig({
  define: {
    __VUE_PROD_HYDRATION_MISMATCH_DETAILS__: "false", // true/false根据需求调整
    __VUE_OPTIONS_API__: "true", // （可选）兼容Options API
    __VUE_PROD_DEVTOOLS__: "false", // （可选）禁用生产环境DevTools
  },
  plugins: [
    vue(),
    AutoImport({
      resolvers: [ElementPlusResolver()],
    }),
    Components({
      resolvers: [ElementPlusResolver()],
    }),
  ],
  server: {
    proxy: {
      // 代理高德地图API请求
      "/amap": {
        target: "https://webapi.amap.com",
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/amap/, ""),
      },
      // 代理天地图请求
      "/tianditu": {
        target: "https://t[1-4].tianditu.gov.cn",
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/tianditu/, ""),
      },
    },
  },
});
